# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=svxlink
pkgver=19.09.1
pkgrel=1
pkgdesc="Advanced radio repeater controller and EchoLink"
url="http://www.svxlink.org"
arch="all"
license="GPL-2.0-or-later"
pkgusers="svxlink"
pkggroups="svxlink"
options="!check" # package doesn't have tests
makedepends="groff cmake alsa-lib-dev popt-dev gsm-dev speex-dev
	 libgcrypt-dev tcl-dev curl-dev libsigc++-dev linux-headers"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="$pkgname-dev $pkgname-doc $pkgname-static"
source="$pkgname-$pkgver.tar.gz::https://github.com/sm0svx/svxlink/archive/$pkgver.tar.gz
	svxlink.initd
	svxlink.confd
	"
builddir="$srcdir"/$pkgname-$pkgver/src

build() {
	cd $builddir
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONF_INSTALL_DIR=/etc \
		-DLOCAL_STATE_DIR=/var \
		-DLIB_INSTALL_DIR=/usr/lib \
		-DBUILD_STATIC_LIBS=ON \
		-DUSE_OSS=NO -DUSE_QT=NO \

	make
	make doc
}

static() {
  depends=""
  pkgdesc="$kgdesc static libraries"
	mkdir -p "$subpkgdir"/usr/lib
  mv "${pkgdir}-dev"/usr/lib/*.a "$subpkgdir"/usr/lib
}

package() {
	cd $builddir
	make DESTDIR="$pkgdir" install
  rm -rf ${pkgdir}/usr/share/doc
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/voice_mail/
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/qso_recorder/
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/propagation_monitor
}

sha512sums="93fb0ac360544244ba1843ed8036ca2772b6207cb9bb34e80a746c195bb024a59ac7b799fd92191b8dec05d2258fb73ea7cc1103aee8bd94491b2e3e480ae0fa  svxlink-19.09.1.tar.gz
39d1a4febfdd5e50b9df21c0e77c80a50af1680a6e001cda3f31fc752b1cba0948c40bf70106579e32c1de37ee76d6dde218824bcac2b013a71b144256f60168  svxlink.initd
1a587c032e73c3a76a1aa8c18d2b3d90a716f49ffb75a5b863da02a59a76a433355e2c1a07f44795545bce01e713890881a14ef9b9d2aae3690e0bf462d432a7  svxlink.confd"
